package com.bookstore.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.bookstore.domain.ShoppingCart;


public class BookStoreWebUtils {
	/**
	* @Title: getShoppingCart
	* @Description: TODO(获取购物车对象,从session中获取，若session中没有该对象
	* 则创建一个新的购物车对象放入到session中,若有则直接返回)
	* @param @param request
	* @param @return    
	* @return ShoppingCartItem    
	* @throws
	* 2017年5月27日
	*/
	public static ShoppingCart getShoppingCart(HttpServletRequest request) {
		HttpSession session = request.getSession();
		ShoppingCart sCart = (ShoppingCart) session.getAttribute("ShoppingCart");
		if (sCart == null) {
			sCart = new ShoppingCart();
			session.setAttribute("ShoppingCart", sCart);
		}
		
		return sCart;
		
	}
}
